import {Button, Form, Input, InputNumber} from "antd";
import {useEffect, useState} from "react";
import { message } from "antd";
import { deviceCommandSending } from "../../service";

const WayBillMgr = ({record}) => {
  const {TextArea} = Input;
  const [commandForm] = Form.useForm();

  const send = () => {
    let values = commandForm.getFieldsValue();
    let requestData = {
      deviceId: record.id,
      commandId: 0x0701,
      params: values
    };

    console.log(requestData)
    deviceCommandSending(requestData).then((res) => {
      message.info(res.msg)
    });
  }
  return (
    <Form form={commandForm}>
      <Form.Item
        label="运单内容"
        name="content"
        rules={[
          {
            required: true,
            message: '请输入运单内容',
          }, {type: 'string', max: 32}
        ]}
      >
        <TextArea
          showCount
          maxLength={1024}
          placeholder="请输入运单内容"
          style={{ height: 120, resize: 'none' }}
        />
      </Form.Item>

      <Form.Item>
        <Button onClick={send}>发送</Button>
      </Form.Item>
    </Form>
  );

}

export default WayBillMgr;